﻿using app.Api;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AmuTools;

namespace app.Models
{
    [Model(TableName = "t_plateform_service", PrimaryKey = "id", IdentityInsert = false)]
    public class PlateformService : ModelBase
    {
        /*
         *
         
         */
        [Field(Description ="平台服务信息的唯一标识")]
        public int id { get; set; }

        [Field(DataType = "nvarchar(MAX)",Description ="平台服务的唯一编号 ：'ps'+时间戳+id")]
        public string number { get; set; }

        [Field(Description ="平台服务标题")]
        public string title { get; set; }

        [Field(DataType = "nvarchar(MAX)",Description ="平台服务描述")]
        public string content { get; set; }

        [Field(DataType = "nvarchar(MAX)",Description ="平台服务流程")]
        public string process { get; set; }

        [Field(Storageable = false,Description ="流程信息")]
        public List<Step> steps
        {
            get
            {
                return Step.GetSteps(id);
            }
        }
        
        private string _appendix_ids = "";   //附件

        private List<UploadedFile> _appendix = null;

        [Field(Description ="附件")]
        public string appendix_ids
        {
            get { return _appendix_ids; }
            set
            {
                _appendix_ids = value;
                _appendix = null;
            }
        }

        [Field(Storageable = false,Description ="附件数组")]
        public List<UploadedFile> appendix
        {
            get
            {
                if (_appendix == null)
                {
                    if (appendix_ids == "") _appendix = new List<UploadedFile>();
                    else _appendix = G.DB.Get<UploadedFile>(string.Format("{0} in ({1})", G.DB.GetPrimaryKey<UploadedFile>(), appendix_ids)).GetFirstTableList<UploadedFile>();
                }
                return _appendix;
            }
        }

        [Field(Description ="建立时间")]
        public string create_time { get; set; }

        [Field(Description = "状态：0删除,1未发布,2已发布")]
        public int status { get; set; }

        [Field(Description ="外部是否可见：0外部不可见，1外部可见")]
        public int isvisiable { get; set; }

    }
}